import {getCompanyList, getCategoryList} from '../api'
export const formItems = [
  {
    label: '组件ID',
    name: 'id',
    type: 'input',
    itemProps: {
      disabled: true
    }
  },
  {
    label: '所属栏目页',
    name: 'category_id',
    value: undefined,
    type: 'select',
    required: true,
    asyncOptions: {
      api: getCategoryList,
      dataField: 'list',
      optionFields: {
        label: 'title',
        value: 'id',
      },
    }
  },
  {
    label: '所属企业',
    name: 'company_id',
    type: 'select',
    value: '0',
    hidden: (formState) => {
      return !formState.category_id
    },
    itemProps: {
      disabled: true
    },
    asyncOptions: {
      api: getCompanyList,
      dataField: 'list',
      optionFields: {
        label: 'name',
        value: 'id',
      },
    }
  },  
  {
    label: '组件名称',
    name: 'title',
    value: '',
    type: 'input',
    required: true,
  },
  {
    label: '模块排列顺序',
    name: 'sort',
    type: 'input-number',
    required: true,
  },
  {
    label: '图片',
    name: 'pic',
    value: [],
    required: true,
    type: 'Uploader',
    itemProps: {
      maxLen: 1
    }
  },
  {
    label: '跳转类型',
    name: 'jump_type',
    required: true,
    type: 'select',
    itemProps: {
      options: [
        {label: '自定义', value: 'custom'},
        {label: '不跳转', value: 'off'},
      ]
    }
  },
  {
    label: '跳转地址',
    name: 'url',
    required: true,
    type: 'input',
    hidden: (formState) => {
      return formState.jump_type != 'custom'
    },
  },
  {
    label: '弹窗频次',
    name: 'rate',
    required: true,
    type: 'radio-group',
    itemProps: {
      options: [
        {label: '仅弹一次', value: 'once'},
        {label: '每次都弹', value: 'every'},
      ]
    }
  },
];

export const formItems2Rules = {

};
